From 6e4eec426ae034a27c2e98ba3e148ce05fbaddd4 Mon Sep 17 00:00:00 2001 From: Stevan Earl Date: Thu, 10 Sep 2026 17:40:36 -0700 Subject: [PATCH] fix: allow Mutual for groom scans --- db/schemas/lib/triggers/create/roles.m4 | 14 +++++++++----- doc/src/tables/events.m4 | 8 ++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/db/schemas/lib/triggers/create/roles.m4 b/db/schemas/lib/triggers/create/roles.m4 index 53b1dad..d50691c 100644 --- a/db/schemas/lib/triggers/create/roles.m4 +++ b/db/schemas/lib/triggers/create/roles.m4 @@ -329,10 +329,10 @@ CREATE OR REPLACE FUNCTION roles_func () IF NEW.role <> 'sdb_actor' AND NEW.role <> 'sdb_actee' AND ((a_behavior = 'sdb_aggression' - OR a_behavior = 'sdb_groom_scan' OR a_behavior = 'sdb_mating_event') OR (NEW.role <> 'sdb_mutual' - AND (a_behavior = 'sdb_groom_scan_a' + AND (a_behavior = 'sdb_groom_scan' + OR a_behavior = 'sdb_groom_scan_a' OR a_behavior = 'sdb_pg_event' OR (NEW.role <> 'sdb_unkpair' AND a_behavior = 'sdb_grooming')))) THEN @@ -373,9 +373,11 @@ CREATE OR REPLACE FUNCTION roles_func () END IF; - IF a_behavior = 'sdb_aggression' - OR a_behavior = 'sdb_groom_scan' - OR a_behavior = 'sdb_mating_event' THEN + IF (NEW.role = 'sdb_actor' + OR NEW.role = 'sdb_actee') + AND (a_behavior = 'sdb_aggression' + OR a_behavior = 'sdb_groom_scan' + OR a_behavior = 'sdb_mating_event') THEN -- Role is sdb_actor or sdb_actee. There can be only one row -- with each of these roles per aggression/grooming/mating -- event. @@ -503,6 +505,8 @@ CREATE OR REPLACE FUNCTION roles_func () -- each role must be distinct. -- IF TG_OP = 'INSERT' + AND (NEW.role = 'sdb_actor' + OR NEW.role = 'sdb_actee') AND (a_behavior = 'sdb_aggression' OR a_behavior = 'sdb_groom_scan' OR a_behavior = 'sdb_mating_event') THEN diff --git a/doc/src/tables/events.m4 b/doc/src/tables/events.m4 index 7074924..6c3139d 100644 --- a/doc/src/tables/events.m4 +++ b/doc/src/tables/events.m4 @@ -459,10 +459,10 @@ The following table lists these rules and implications: There should be exactly two |ROLES| row related to the grooming interval sampling event. - The only two |ROLES|.\ |ROLES.Role| codes allowed are ``sdb_actor`` and - ``sdb_actee``. - One of those two roles must be ``sdb_actor`` and the other must be - ``sdb_actee``. + Only the codes ``sdb_actor``, ``sdb_actee``, and ``sdb_mutual`` + may be used as |ROLES|.\ |ROLES.Role| code values. + When the roles are not ``sdb_mutual``, one must be ``sdb_actor`` + and the other must be ``sdb_actee``. The system will generate a warning when there are not exactly two |ROLES| rows related to an grooming event. -- 2.34.1